

/**

 ║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║
 ║║  ______           _                                                          _                _      ║║
 ║║ |  ____|         | |                               /\                       | |              | |     ║║
 ║║ | |__     _   _  | |_   _   _   _ __    ___       /  \     _ __    _ __     | |        __ _  | |__   ║║
 ║║ |  __|   | | | | | __| | | | | | '__|  / _ \     / /\ \   | '_ \  | '_ \    | |       / _` | | '_ \  ║║
 ║║ | |      | |_| | | |_  | |_| | | |    |  __/    / ____ \  | |_) | | |_) |   | |____  | (_| | | |_) | ║║
 ║║ |_|       \__,_|  \__|  \__,_| |_|     \___|   /_/    \_\ | .__/  | .__/    |______|  \__,_| |_.__/  ║║
 ║║                                                           | |     | |                                ║║
 ║║                                                           |_|     |_|                                ║║
 ║║                                                                                                      ║║
 ║║           ******************************************************************************             ║║
 ║║                                                                                                      ║║
 ║║                 ___                 _      _     ____  _                               _   _         ║║
 ║║                |   \   __ _  __ __ (_)  __| |   |_  / (_)  _ __    _ __    ___   _ _  | | (_)        ║║
 ║║                | |) | / _` | \ V / | | / _` |    / /  | | | '  \  | '  \  / -_) | '_| | | | |        ║║
 ║║                |___/  \__,_|  \_/  |_| \__,_|   /___| |_| |_|_|_| |_|_|_| \___| |_|   |_| |_|        ║║                                
 ║║                ______________________________________________________________________________        ║║
 ║║                                                                                                      ║║
 ║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║║
 

 */
package Cards;

import java.util.ArrayList;



public class getCard {
	static int randomColor;
	static ArrayList<Card> shuffleCards = new ArrayList<Card>();
	static int numberOfPlayers = 3;
	
	
	public static void main(String[] args){
			cardInitializer.cardInitializer();
			

		}

	public static  void shuffle(ArrayList<Card> redCards,
			ArrayList<Card> yellowCards, ArrayList<Card> orangeCards, ArrayList<Card> greyCards, ArrayList<Card> greenCards) {

		
			int redCardsLeft = 9;
			int yellowCardsLeft = 9;
			int orangeCardsLeft = 9;
			int greyCardsLeft = 9;
			int greenCardsLeft = 9;
			int totalCards =45;
			int countCards = 0;
			int cardNumber;
			boolean twoPlayers;
			
			
			if (numberOfPlayers ==2){
				twoPlayers = true;
				totalCards = 36;
			}else{
				twoPlayers = false;

			}
	
	
		for (int i = 0; countCards < totalCards; i++){
		
		 randomColor = random.randomColor(numberOfPlayers);
		 switch (randomColor) {
         case 1:  randomColor = 1 ;
         		 if (redCardsLeft >0){
         			cardNumber =random.randomNumber(redCardsLeft);
         			 shuffleCards.add(redCards.get(cardNumber));
         			 redCards.remove(cardNumber);
         			 redCardsLeft = redCardsLeft -1;
         			 countCards = countCards + 1;
         		 }
                  break;
         case 2:  randomColor = 2;
         		  if (yellowCardsLeft >0){
         			 cardNumber =random.randomNumber(yellowCardsLeft);
         			 shuffleCards.add(yellowCards.get(cardNumber));
         			yellowCards.remove(cardNumber);
         			yellowCardsLeft = yellowCardsLeft -1;
         			 countCards = countCards + 1;
         		  }
                  break;
         case 3:  randomColor = 3;
         			if (orangeCardsLeft > 0){
         				cardNumber =random.randomNumber(orangeCardsLeft);
            			 shuffleCards.add(orangeCards.get(cardNumber));
            			 orangeCards.remove(cardNumber);
            			 orangeCardsLeft = orangeCardsLeft -1;
            			 countCards = countCards + 1;
         			}
                  break;
         case 4:  randomColor = 4;
         			if (greyCardsLeft > 0){
         				cardNumber =random.randomNumber(greyCardsLeft);
            			 shuffleCards.add(greyCards.get(cardNumber));
            			 greyCards.remove(cardNumber);
            			 greyCardsLeft = greyCardsLeft -1;
            			 countCards = countCards + 1;
         			}
         			break;
                  
         case 5:
        	 randomColor = 5;
				if (greenCardsLeft >0){
					cardNumber =random.randomNumber(greenCardsLeft);
					shuffleCards.add(greenCards.get(cardNumber));
					greenCards.remove(cardNumber);
					greenCardsLeft = greenCardsLeft -1;
					countCards = countCards + 1;
				}

        	 break;
		 }// End Switch
		 
		
		 }// END For 
      
	/**	For Testing
	 * 
	 * for (Card shuffle : shuffleCards){
	//		 System.out.println(shuffle.getCardName());
		
     }
     */
		
		dealOutCards.dealOutCards(shuffleCards, twoPlayers);
	
		
	} // END public static void shuffle(...)

}// END cardshuffler
